TableTruncating
申请清理表
请求地址
POST
http://OmsAddress/app/newoms.php/webservice/business/table/truncating?cmd=10004&ip-type=webservicerest&access-token=AccessTokenVal
POST请求参数说明
参数名称 | 数据类型 | 说明 | 是否必填字段 | 备注 |
---|---|---|---|---|
app_id | 整型 | 清理表所在的业务id | 是 | |
zone_id | 整型 | 清理表所在的游戏区id | 是 | |
table_name | 字符串、字符串数组 | 清理表的表名,多个表时,可使用数组传递表名称,数组中的数据项为表名称(例如:["table1","table2","table3"....]) | 是 | 推荐单个表操作清表,多个表提单清表涉及到后台资源锁定可能会没有执行优先权 |
auto_approve | 整型(0或1) | 是否自动审核清理表(表所在集群允许自动审核表清理申请) | 否,默认不自动审核 | |
auto_exec_trans | 整型(0或1) | 是否执行自动审核清理表申请后,生成清理表事务(表所在的集群允许自动执行清理表事务,auto_approve=1时,auto_exec_trans=1才有效) | 否,默认不自动执行 | |
attention_man | 字符串 | 用分号";"分隔关注人,关注人可执行此单据任务,字段最大长度为200 | 否 |
Data参数
使用json格式表示记录相关信息,示例如下:
{
"app_id": 2,
"zone_id": 3,
"table_name": "test_table_generic_modify",
"auto_approve": 1,
"auto_exec_trans": "",
}
返回语法
返回参数说明
参数名称 | 数据类型 | 说明 | 备注 |
---|---|---|---|
apply | json | ret:表示是否申请成功,0表示成功;其他表示失败 msg:表示ret不等于0时的错误信息 info:申请成功的清理表单据,其中uid表示单据id,审核清理表申请时需要此值 | |
check | json | ret:表示是否审核成功,0表示成功;其他表示失败 msg:表示ret不等于0时的错误信息 info:其中trans_id表示生成的清理表的事务,set_id表示事务所在的集群(表所在的集群) |
请求示例
通过 curl 方法发起请求
命令中的参数请参考本页中的“POST请求参数说明”,access-token的获取方法详见:获取access-token
curl -H "Content-type: application/json" -X "POST" -d '{
"app_id": 2,
"zone_id": 3,
"table_name": "test_table_generic_modify",
"auto_approve": 1,
"auto_exec_trans": "" }' http://omsaddress/app/newoms.php/webservice/business/table/truncating?cmd=10004&ip-type=webservicerest&access-token=<access-token>
返回示例
成功返回示例
http请求的Status=200
{
"apply": {
"ret": 0,
"msg": "success to apply truncate table",
"info": {
"app_id": 2,
"app_name": "t_app",
"set_id": 126,
"zone_list": "3",
"table_name": "test_table_generic_modify",
"table_type": 0,
"estimated_write_load": 0,
"estimated_read_load": 0,
"type": "xml",
"table_maxnum": 0,
"write_time": "2017-03-02 21:52:25",
"apply_type": 2,
"key_avarage_record_size": 1,
"value_avarage_record_size": 1,
"compress": 0,
"active_record_num": "0",
"total_record_num": "3",
"memo": "",
"tdr": "-1",
"pcu": 1,
"relationship_chain_interval": 60,
"relationship_chain_count": 1,
"index_count": 1,
"read_index_interval": 60,
"read_index_count": 1,
"read_interval": 60,
"write_interval": 60,
"calc_resource_type": 2,
"dm_ratio": 5,
"user": "tcaplus",
"job_id": "42",
"id": 112,
"task_id": 407,
"trans_id": 407,
"execute_user": "tcaplus",
"execute_status": 1,
"audit_memo": ""
},
"find_dba": {
"need_find_dba": 0,
"dba_name": "eteet"
}
},
"check": {
"ret": 0,
"msg": "",
"info": {
"set_id": 126,
"trans_id": 407
}
}
}
错误返回
http请求的Status!=200 如1:没有权限,token认证失败
{
"name": "Unauthorized",
"message": "You are requesting with an invalid credential.",
"code": 0,
"status": 401,
"type": "yii\\web UnauthorizedHttpException"
}
2.操作的表已经申请其他操作,需要先处理之前的申请单据
{
"apply": {
"ret": -1,
"msg": "table_name:已经申请其他表操作 app:2 zone:3 table_name:test_table_generic_modify apply id:113 apply type:2 error type:1",
"info": null
}
}